﻿@model BrnMall.Web.StoreAdmin.Models.StoreClassModel
           
@section header{
    <title>添加店铺分类</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css"/>
    <link type="text/css" rel="stylesheet" href="/components/webuploader/webuploader.css" />
    
    <script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
    <script type="text/javascript" src="/components/webuploader/webuploader.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.unobtrusive.js"></script>
    <script type="text/javascript">
        $(function () {

            var uploader = WebUploader.create({
                pick: '.uploadBut',
                auto: true,
                swf: '/components/webuploader/Uploader.swf',
                server: '/storeadmin/tool/upload?operation=SaveUploadStoreClass',
                fileVal: 'upload',
                accept: {
                    title: 'Images',
                    extensions: '@ViewData["allowImgType"]',
                    mimeTypes: '*'
                },
                fileSingleSizeLimit: @ViewData["maxImgSize"]
            });

            uploader.on('uploadProgress', function(file, percentage) {
                $(".uploadPreview").html("上传中...");
            });

            uploader.on('uploadSuccess', function(file, response) {
                var data = response._raw;
                if (data == "-1")
                    $(".uploadPreview").html('图片不能为空');
                else if (data == "-2")
                    $(".uploadPreview").html('图片类型不允许');
                else if (data == "-3")
                    $(".uploadPreview").html('图片太大');
                else {
                    $(".uploadPreview").html("<img src=\"@WorkContext.ImageCDN/upload/store/@WorkContext.StoreId/classes/source/" + data + "\"  />");
                    $("#Logo").val(data);
                }
            });

            uploader.on('uploadError', function(file) {
                $(".uploadPreview").html("上传失败");
            });

        });
    </script>
}
@section body{
    <h1 class="rightH1">
		微信小程序 &gt; 店铺管理 &gt; <span class="rightH1-cur">添加店铺分类</span>
        <div class="right">
            <a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/admin_store/images/goback.jpg" />返回列表</a>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </h1>
    <div class="addTable">
        @using (Html.BeginForm())
        {
            <table width="100%">
                <tr>
                    <td width="76px" align="right">分类名称：</td>
                    <td>@Html.TextBoxFor(x => x.StoreClassName, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.StoreClassName)
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        所属分类：
                    </td>
                    <td>
                        <select data-val="true" data-val-number="字段 ParentId 必须是一个数字。" data-val-range="请选择分类" data-val-range-max="2147483647" data-val-range-min="0" data-val-required="ParentId 字段是必需的。" id="ParentId" name="ParentId">
                            <option @if (0 == Model.ParentId){<text>selected="selected"</text>} value="0">顶层分类</option>
                            @foreach (StoreClassInfo info in ViewData["storeClassList"] as List<StoreClassInfo>)
                            {
                                <option @if (info.StoreCid == Model.ParentId){<text>selected="selected"</text>} value="@info.StoreCid">@Html.Raw(CommonHelper.GetHtmlBS(info.Layer - 1)) @info.Name</option>
                            }
                        </select>
                        @Html.ValidationMessageFor(x => x.ParentId)
                    </td>
                </tr>
                <tr>
                    <td align="right">Logo：</td>
                    <td>
                        <div class="upload">
                            <div class="uploadPreview">
                                @if (!string.IsNullOrEmpty(Model.Logo))
{
    <img width="75" height="75" src="@WorkContext.ImageCDN/upload/store/@WorkContext.StoreId/classes/source/@Model.Logo" />
}
else
{
                                    @:暂无图片
                                }
                            </div>
                            <div class="left">
                                <div class="uploadProgressBar"></div>
                                <div class="uploadBut">选择图片,图片比例3：1，最低240x80</div>
                            </div>
                            <div class="clear"></div>
                        </div>
                        @Html.TextBoxFor(x => x.Logo, new { @class = "hide" })
                        @Html.ValidationMessageFor(x => x.Logo)
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        排序：
                    </td>
                    <td>@Html.TextBoxFor(x => x.DisplayOrder, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.DisplayOrder)
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        &nbsp;
                    </td>
                    <td>
                        <a href="" class="addBt" id="sumbitBut">
                            <img src="/admin_store/images/submit.jpg" /></a>
                        <script type="text/javascript">
                            $(function () {
                                $("#sumbitBut").click(function () {
                                    $("form:first").submit();
                                    return false;
                                })
                            });
                        </script>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        }
    </div>
}
